# Copyright (c) 2019 Presto Labs Pte. Ltd.
# Author: leon

from coin.exchange.okex_futures.book_builder import BookBuilder
from coin.exchange.okex_futures.kr_rest.futures_product import OkexFuturesProduct
from coin.exchange.okex_base.okex_v3_handler_base import OkexV3HandlerBase


class SwapTraits(object):
  @classmethod
  def get_qty_from_trade(cls, trade_msg, timestamp):
    return float(trade_msg['size'])

  @classmethod
  def get_product_from_instrument_id(cls, instrument_id, timestamp):
    return OkexFuturesProduct.FromStrNativeProductV3(instrument_id)


class OkexFuturesSwapHandler(OkexV3HandlerBase):
  BookBuilderType = BookBuilder
  TraitsType = SwapTraits
